package com.caiyi.financial.nirvana.sms.controller;

import com.caiyi.financial.nirvana.sms.entity.SmsGateway;
import com.caiyi.financial.nirvana.sms.querybean.QueryGatewayBean;
import com.caiyi.financial.nirvana.sms.service.SmsGatewayService;
import com.youyu.common.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "通道管理")
@CrossOrigin
@RestController
@RequestMapping("sms/admin/gateway")
public class GatewayController {
    @Autowired
    private SmsGatewayService smsGatewayService;

    @ApiOperation(value = "添加Gateway详情", notes = "添加Gateway详情描述")
    @ApiImplicitParam(name = "smsGateway", value = "网关", required = true, dataType = "SmsGateway", paramType = "body")
    @PostMapping("/addGateway")
    public Result addGateway(@RequestBody SmsGateway smsGateway) {
        return Result.ok(smsGatewayService.addGateway(smsGateway));
    }

    @ApiOperation(value = "根据运营商查询网关", notes = "根据运营商查询网关")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "operator", value = "运营商类型", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/queryByOperator")
    public Result queryByOperator(Integer operator) {
        return Result.ok(smsGatewayService.queryByOperator(operator));
    }

    @ApiOperation(value = "删除Gateway详情", notes = "删除Gateway")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "网关id", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteGateway")
    public Result deleteGateway(Integer id) {
        return Result.ok(smsGatewayService.deleteGateway(id));
    }

    @ApiOperation(value = "更新Gateway详情", notes = "更新Gateway")
    @ApiImplicitParam(name = "smsGateway", value = "网关", required = true, dataType = "SmsGateway", paramType = "body")
    @PostMapping("/updateGateway")
    public Result updateGateway(@RequestBody SmsGateway smsGateway) {
        return Result.ok(smsGatewayService.updateGateway(smsGateway));
    }

    @ApiOperation(value = "修改通道状态详情", notes = "修改通道状态详情描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "通道id", required = true, dataType = "int", paramType = "query")
    })
    @PostMapping("/changeStatus")
    public Result changeStatus(Integer id) {
        return Result.ok(smsGatewayService.updateStatus(id));
    }

    @ApiOperation(value = "根据params查找Gateway详情", notes = "根据params查找Msg详情描述")
    @ApiImplicitParam(name = "bean", value = "查找网关参数", required = true, dataType = "QueryGatewayBean", paramType = "body")
    @PostMapping("/getGatewayByParams")
    public Result getGatewayByParams(@RequestBody QueryGatewayBean bean) {
        return Result.ok(smsGatewayService.getGatewayByParams(bean));
    }

    @ApiOperation(value = "获取所有通道name,id", notes = "获取所有通道name,id详情描述")
    @PostMapping("/getGatewayId")
    public Result getGatewayId() {
        return Result.ok(smsGatewayService.getGatewayId());
    }

}
